package com.kygeng.springframework.common;

import com.kygeng.springframework.beans.BeansException;
import com.kygeng.springframework.beans.PropertyValue;
import com.kygeng.springframework.beans.PropertyValues;
import com.kygeng.springframework.beans.factory.ConfigurableListableBeanFactory;
import com.kygeng.springframework.beans.factory.config.BeanDefinition;
import com.kygeng.springframework.beans.factory.config.BeanFactoryPostProcessor;

public class UserInfoBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("UserInfoBeanFactoryPostProcessor # postProcessBeanFactory");
        BeanDefinition personBeanDefiniton = beanFactory.getBeanDefinition("userInfo");
        PropertyValues propertyValues = personBeanDefiniton.getPropertyValues();
        //将userInfo的name属性改为小明明
        propertyValues.addPropertyValue(new PropertyValue("name", "小明明"));
    }
}